-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: improve css render performance #1476
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great findings 👍
@@ -16,7 +16,41 @@ useSeoMeta({ | |||
twitterImage: joinURL(site.url, '/new-social.jpg') | |||
}) | |||
</script> | |||
|
|||
<style> | |||
.content-visibility-auto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would probably be nice to define these Tailwind utils "globally" 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! where can i put them??
I'm a beginner vue coder just so u be humble with my ugly code :D
@@ -45,6 +45,29 @@ defineShortcuts({ | |||
|
|||
const { copy } = useCopyToClipboard() | |||
</script> | |||
<style> | |||
#module-categories { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose these could be moved to tailwind-equivalents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you give me more info what this means I'll do it right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually global classes are added as a plugin in Tailwind. As a matter of fact, the docs feature an example using content-visibility
here: https://tailwindcss.com/docs/plugins#prefix-and-important (and !important
, which is not relevant for your use case).
But, bear in mind that I'm an outsider, don't take this comment as actual advice of what to do since the Nuxt team could have a different answer. 👍🏽😉🤗
Co-authored-by: Alexander Lichter <github@lichter.io>
Okay, let's see how we do that: Tailwind does not provide utils for For For the "more specific CSS" - I wonder if we either could fix this straight away in the UI library. img, svg, span[class^="i-ph"] {
contain:content;
}
span[class^="i-ph"] {
content-visibility: auto;
contain-intrinsic-size: 20px;
} For Let me know if you have any questions |
Excellent description! 😍 Helps a lot. Thx for your time! 🙏 |
.contain-intrinsic-size-500 { | ||
contain-intrinsic-size: 200px; | ||
} | ||
.contain-intrinsic-size-800 { | ||
contain-intrinsic-size: 200px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that correct ?
.contain-intrinsic-size-500 { | |
contain-intrinsic-size: 200px; | |
} | |
.contain-intrinsic-size-800 { | |
contain-intrinsic-size: 200px; | |
} | |
.contain-intrinsic-size-500 { | |
contain-intrinsic-size: 500px; | |
} | |
.contain-intrinsic-size-800 { | |
contain-intrinsic-size: 800px; | |
} |
Any thoughts @benjamincanac? |
I'm not familiar with those CSS properties so I won't be much of a help but I agree with @manniL's review to improve how those properties are defined using a plugin / arbitrary values. @BioPhoton Do you plan to make the changes? |
Hi just saw it. I'll push what I have tomorrow afternoon latest 🙌 |
The Problem
The page has hight render time especially for recalculate styles layout also paint is not optimal.
Steps to reproduce
You should see a heavy delay in responsive ness due to heavy recalc and layouting.
Measurement
Desktop unthrottled
Desktop 4x throttled
Mobile unthrottled
Mobile 4x throttled
Solution
Use CSS techniques that improve rendering
Poc
To get quick insight how the changes improve rendering I used source overwrites in the Chrome DevTools.
Here the used snippet:
This PR includes
style adoptions as well as adding img lazy loading in the following files:
Measurement before/after 4x throttled
Mini map comparison
Mini map comparison inc CWV plugin
Im happy to adjust/move code around as I am not really familiar with the code base and assume the location of the code could be improved...
All theory on the improvements can be found here: https://github.com/push-based/css-contain-and-content-visibility-research